<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title>运营平台</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="renderer" content="webkit">
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge">-->
<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/common.css?v=20170207" />
<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/table.css?v=20170117" />
<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/jquery-ui.css" />
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery-1.11.1.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery-ui.min.js" type="text/javascript"></script>
 <script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/yunIndex.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery-ym-datePlugin-0.1.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/global.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/cheshan/js/common.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery.placeholder.min.js"></script>
<script type="text/javascript">
 $(function(){
     $("input").placeholder();
     if (navigator.userAgent.indexOf("Safari") > -1) {
       $("input").css("lineHeight","normal !important");
     };
});
</script>

</head>
<body>

<body>
<div class="header">
<div class="headerCo">
<span>你好,<?php echo ($user_info["real_name"]); ?><a href="<?php echo (WEB_URL); ?>Emp/logout">退出</a></span>
<h1><img src="<?php echo get_style_cdnurl();?>paimai/yunying/images/yun_logo.jpg"></h1>
</div>
</div>

<div class="mian">
    <div class="mianL">
    <dl>
        <dd>
            <a id="menu_sy" href="/Index/index" class="shouye">首页</a>
        </dd>
        <?php foreach ($tree_menu as $key => $value): ?>
          <dd>
            <span id="menu_<?php echo ($value['first_char']); ?>" ><img src="<?php echo get_style_cdnurl();?>paimai/yunying/images/yun_jia.jpg"><?php echo ($value['name']); ?></span>
            <ul style="display: none;">
                <?php if (!empty($value['children'])): ?>
                    <?php foreach ($value['children'] as $k => $v): ?>
                        <li><a id='menu_<?php echo ($v["first_char"]); ?>' href="<?php echo ($v['url']); ?>"><?php echo ($v['name']); ?></a></li>
                    <?php endforeach ?>
                <?php endif ?>
            </ul>
        <?php endforeach ?>
    </dl>
</div>

<?php $menu = 'zhgl.ygzh'; ?>
<?php $menu=json_encode(explode('.', $menu)); ?>
<script>
    $(function () {
        var cur_menu = '<?php echo ($menu); ?>', cur_menu = eval('[' + cur_menu + ']'), cur_menu = cur_menu[0];
        if (cur_menu == "sy") {
            $("#menu_sy").removeClass('shouye').addClass('current');
        }
        $('#menu_' + cur_menu[0]).click();
        $('#menu_' + cur_menu[0]).find("img").attr("src", "http://img1.isou365.cn/paimai/yunying/images/yun_jie.jpg");
        $(".mianL").css("height", $(document).height() - 95);
        $('#menu_' + cur_menu[1]).addClass('current');
    });
</script>

    <form id='ct_fm' action="/Emp/ci_group_save" method="post">
        <input type="hidden" name="group_id" value="<?php echo ($group["id"]); ?>" />
        <div class="mianR">
            <h3 class="yonghu"><?php echo ($_GET['group_id']?'编辑':'新建');?>分组</h3>
            <div class="new-fenzu">
                <dl>
                    <dt class="clearfix">
                        <span>分组名称</span>
                        <input type="text" name="title" value="<?php echo ($group["title"]); ?>" />
                        <span>分组描述</span>
                        <input type="text" name="remark" value="<?php echo ($group["remark"]); ?>" />
                    </dt>
                    <dd>
                        
                        <div class="xinzeng clearfix">                        
                            <h4>权限分配</h4> <input type="button" onclick="create_emp();" value="新增权限" /> </a>
                        </div>
                        <?php if(is_array($rule_list)): foreach($rule_list as $k=>$rule): if(($rule["pid"] == 0)): if(($k != 0)): ?></em><?php endif; ?>
                                <span><input type="checkbox" <?php echo (in_array($rule['id'], $group['rule_id'])?'checked':''); ?>  name="rule_id[]" value="<?php echo ($rule["id"]); ?>" /><?php echo ($rule["title"]); ?></span> 
                                <em class="clearfix">
                            <?php else: ?> 
                                <i><input type="checkbox" <?php echo (in_array($rule['id'], $group['rule_id'])?'checked':''); ?>  name="rule_id[]" value="<?php echo ($rule["id"]); ?>"  /><?php echo ($rule["title"]); ?></i><?php endif; endforeach; endif; ?>

                        <!-- <span><input type="checkbox" />卖车用户</span> 
                        <em class="clearfix">
                            <i><input type="checkbox"  name="rule_id[]" value="1"  />待预约</i>  
                            <i><input type="checkbox"  name="rule_id[]"  value="2"  />跟踪中</i> 
                            <i><input type="checkbox"  name="rule_id[]"  value="3"  />预约成功</i>
                            <i><input type="checkbox"  name="rule_id[]"  value="4" />预约失败</i>
                            <i><input type="checkbox"  name="rule_id[]"  value="5"  />新增用户信息</i>
                        </em> 
                        
                        
                        <span><input type="checkbox" />卖车用户</span> 
                        <em class="clearfix">
                            <i><input type="checkbox"  name="rule_id[]" value="6" />待预约</i>  
                            <i><input type="checkbox"  name="rule_id[]" value="7" />跟踪中</i> 
                            <i><input type="checkbox"  name="rule_id[]" value="8" />预约成功</i>
                            <i><input type="checkbox"  name="rule_id[]"value="9"  />预约失败</i>
                            <i><input type="checkbox"  name="rule_id[]" value="10" />新增用户信息</i>
                        </em>  -->

                    </dd>
                </dl>
            </div>
            <div class="yongBtn">
                <input type="button" onclick="return Submit();" value="确定" class="queding" />
                <input name="重置" type="reset" class="quxiao" onclick="history.go(-1);"  value="取消" />
            </div>
        </div>
    </form>
</div>

</div>
<div class="clear"></div>
</div>





<div class="yunBei" style="display: none;"></div>
<div class="popup" style="margin-top: -259.5px;display:none;">
	<h3>添加权限</h3>
	<form id='ct_fm2' action="/Emp/ci_rule_save" method="POST">
	<input name="rule_id" value="" type="hidden" />
	<ul>
		<li class="clearfix">
			<span>*标识(字母)</span>
			<input type="text" name="name" value=""></li>
		<li class="clearfix">
			<span>*权限标题</span>
			<input type="text" value="" name="title"></li>
		
		<input type='hidden' id='pid' name="pid" value="" />
		<li class="popup-btn clearfix">
			<span>父权限ID</span>
			<input type="text" value="" readonly="">
			<ul class="popup-list" style="display: none;">
				<?php foreach ($rule_list as $key => $value): if($value['pid']=='0'){ ?>
					<li onclick="$('#pid').val('<?php echo $value['id'];?>');popup(this);" ><?php echo $value['title'] ?></li>	
				<?php
 } endforeach ?>
			</ul>
		</li>




		

		<li class="clearfix">
			<input type="button" value="确定" class="queding">
			<input type="button" value="取消" class="quxiao"></li>
	</ul>
	</form>
</div>
<script>
	function create_emp(){
		var bg = $('.yunBei'),pp = $('.popup'),cfm=$('.queding'),cl=$('.quxiao');
		bg.show();
		pp.show();
		$([bg,cfm,cl]).each(function(i,n){
			$(n).unbind('click');
		});
		bg.click(hide_pp);	
		cl.click(hide_pp);
		cfm.click(function(){
			post_submit_json('ct_fm2',function(data){
				//成功回调
				delay_alert('添加权限成功',300);
				setTimeout(function(){
					window.location.reload();	
				},300);
			});
		});
		function hide_pp(){
			bg.hide();
			pp.hide();
			bg.unbind('click');
		};
	};	
</script>


<script>
    $('dd span input').click(function(){
        var checked = (this.checked?true:false);
        $.each($(this).parent().next('.clearfix').find('input'),function(i,n){
            n.checked=checked;
        });
    })
    $('dd em i input').click(function(){            
        if($(this).parent().parent().find("input:checked").length>0){
            $(this).parents("em").prev("span").find("input").prop("checked",true);
        }else{
            $(this).parents("em").prev("span").find("input").removeProp("checked");
        }
    })
</script>
<script>
    function Submit(){
        post_submit_json('ct_fm',function(data){
            //成功回调
            delay_alert('操作成功',300);
            setTimeout(function (){location.href='/Emp/group_list';},400);
        })    
        return false;
    }

</script>
<div class="yunBei"></div>
<div class="loading"></div>
</body>
</html>